package com.connector.server.util;

import org.slf4j.LoggerFactory;
import com.connector.base.connection.Connection;
import com.connector.base.connection.channel.SocketChannel;
import java.util.concurrent.ConcurrentMap;
import com.connector.server.jmx.JmxMessageBean;
import com.connector.base.connection.impl.LocalConnectionRegistry;
import com.connector.server.config.ExecutorProcessPool;
import org.slf4j.Logger;

public class PushMsgUtil
{
    private static final Logger log;

    public static void pushHandshakeMsg(final String userId) {
        final ExecutorProcessPool pool = ExecutorProcessPool.getInstance();
        final ConcurrentMap<SocketChannel, Connection> cons = LocalConnectionRegistry.getConnections();
        pool.execute(new PushMsgUtilThread("2", userId, null, cons));
    }

    public static void pushMsg(final JmxMessageBean jmxMessageBean) {
        final ExecutorProcessPool pool = ExecutorProcessPool.getInstance();
        final ConcurrentMap<SocketChannel, Connection> cons = LocalConnectionRegistry.getConnections();
        pool.execute(new PushMsgUtilThread("1", null, jmxMessageBean, cons));
    }

    public static void pushHandshakeCheckMsg(final Connection connection, final String message) {
        final ExecutorProcessPool pool = ExecutorProcessPool.getInstance();
        pool.execute(new PushMsgUtilThread(connection, message, "3"));
    }

    public static void pushHandshakeCheckAppMsg(final Connection connection, final String message) {
        final ExecutorProcessPool pool = ExecutorProcessPool.getInstance();
        pool.execute(new PushMsgUtilThread(connection, message, "5"));
    }

    public static void pushOtherMsg(final String userId, final String message) {
        final ExecutorProcessPool pool = ExecutorProcessPool.getInstance();
        final ConcurrentMap<SocketChannel, Connection> cons = LocalConnectionRegistry.getConnections();
        pool.execute(new PushMsgUtilThread("4", userId, null, cons, message));
    }

    static {
        log = LoggerFactory.getLogger((Class)PushMsgUtil.class);
    }
}
